home
***
CD-ROM
|
disk
|
FTP
|
other
***
search
/
Shareware Grab Bag
/
Shareware Grab Bag.iso
/
007
/
btrees2.arc
/
BTUSE.C
< prev
next >
Wrap
Text File
|
1984-12-14
|
2KB
|
80 lines
/* sample user program to test btsys */
struct {
unsigned fcode;
unsigned keylen;
unsigned filhand;
unsigned datapt;
char filkey[17];
char filnam[15];
} btstruct, *structp = &btstruct;
main ()
{
int code, number;
char literal[17];
int retcode;
do {
printf ("enter function code\n");
scanf ("%d", &code);
switch (code) {
case 0 : /* initialize system */
structp->fcode = code;
retcode = btfunc (structp);
break;
case 1 : /* file create */
case 2 : /* file open */
printf ("enter file name\n");
scanf ("%s", literal);
strcpy (structp->filnam, literal);
printf ("enter keylength\n");
scanf ("%d", &number);
structp->keylen = number;
structp->fcode = code;
retcode = btfunc (structp);
printf ("retcode %d filhand %d\n",
retcode, structp->filhand);
break;
case 3 : /* file close */
printf ("enter file handle\n");
scanf ("%d", &number);
structp->filhand = number;
structp->fcode = code;
retcode = btfunc (structp);
printf ("retcode %d from close\n", retcode);
break;
case 4 : /* insert keys */
printf ("enter file handle\n");
scanf ("%d", &number);
structp->filhand = number;
printf ("enter key\n");
scanf ("%s", literal);
strcpy (structp->filkey, literal);
printf ("enter data pointer\n");
scanf ("%d", &number);
structp->datapt = number;
structp->fcode = code;
retcode = btfunc (structp);
printf ("retcode %d from insert\n", retcode);
break;
case 5 : /* random read */
printf ("enter file handle\n");
scanf ("%d", &number);
structp->filhand = number;
printf ("enter key\n");
scanf ("%s", literal);
strcpy (structp->filkey, literal);
structp->fcode = code;
retcode = btfunc (structp);
printf ("retcode %d key %s datapt %d\n",
retcode, structp->filkey, structp->datapt);
break;
default : break;
} /* end switch */
} while (code != -1);/* end while */
} /* end btuse */